﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for ProBPRegister
/// </summary>
public class ProBPRegister
{
    public ProBPRegister()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public DataSet LoadBPList()
    {
        DataSet ds = new DataSet();
        ConnectDB db = new ConnectDB();
        ds = db.getListPartner();
        return ds;
    }


    public Boolean AddBusParter(BusinessInfo bsiBusInfo)
    {
        ConnectDB db = new ConnectDB();
        Boolean bResult = db.addBusParter(bsiBusInfo);
        return bResult;
    }

    public Boolean UpdateBusParter(BusinessInfo bsiBusInfo)
    {
        ConnectDB db = new ConnectDB();
        Boolean bResult = db.updateBusPartner(bsiBusInfo);
        return bResult;
    }

    public Boolean DeleteBusPartner(String strCode)
    {
        Boolean bResult = false;
        ConnectDB db = new ConnectDB();
        bResult = db.deleteBusPartner(strCode);
        return bResult;
    }

    public String GenerateNewBPId()
    {
        DataSet ds = new DataSet();
        ConnectDB db = new ConnectDB();
        ds = db.getListPartner();

        int iCurrentCode = 0;
        if (ds.Tables[0].Rows.Count > 0)
            iCurrentCode = Int32.Parse(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["code"].ToString());
        else
            iCurrentCode = 0;
        int iNewCode = iCurrentCode + 1;

        return iNewCode.ToString();
    }

}
